<?php

class Pointconfig extends \Eloquent {
	protected $fillable = [];

    /**
     * @param $item 增加积分操作
     * @param $city 所在城市
     * @return float 积分
     */
    public static function get_points($item,$city,$type){
        $pointconfig = Pointconfig::where('item',$item)->first();
        $arr = unserialize($pointconfig->city_percent);
        if(isset($arr[$city])){
            $new_count = (float)$pointconfig->count;
            $new_count = $new_count*$arr[$city];
            $new_count = round($new_count);
            $base =  $new_count;
        }else{
            $base = $pointconfig->count;
        }
        if($type == 4){
            $p = 0.025;
        }elseif($type == 5){
            $p = 0.05;
        }else{
            $p = 0;
        }
        $true_point = $base+$base*$p;
        return $true_point;
    }
}